<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>


    <script>
        var xhr = new XMLHttpRequest();

        xhr.onload = function () {
            console.log(JSON.parse(xhr.responseText));
        }

        xhr.onerror = function () {
            if (xhr.status == 404) {
                console.log('no found');
            } else if (xhr.status == 400) {
                console.log('请求参数错误');
            } else if (xhr.status == 500) {
                console.log('后台代码出错');
            } else {
                console.log('未知错误');
            }
        }

        xhr.onprogress = function () {
            console.log(event.loaded, event.total);
            console.log('当前进度', (event.loaded / event.total) * 100 + '%');
        }

        xhr.open('GET', 'http://www.bufantec.com/api/test/user/list?start=1&limit=10')
        xhr.send(null);
    </script>
</body>
</html>